package com.ztgf.shopping.api.client.shop;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.shop.ShopOperationBO;
import com.ztgf.shopping.models.service.shop.IShopOperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @author: chenyu.wang
 * @date: 2020-08-19
 * @description:店铺运营控制器
 */
@RestController
@RequestMapping("/api/shopOperationApi")
@Api(value = "ShopOperationApiController", tags = "店铺运营接口")
public class ShopOperationApiController {

    @DubboReference
    private IShopOperationService shopOperationService;

    @PostMapping(value = "/queryShopSignedNum")
    @ApiOperation(value = "销售额统计,获取待签收订单数量和待收货款", notes = "销售额统计,获取待签收订单数量和待收货款")
    private Result queryShopGoodsCount(Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryShopSignedNum(shopId));
    }

    @PostMapping(value = "/queryShopSales")
    @ApiOperation(value = "销售额统计,店铺运营销售额统计树状图", notes = "销售额统计,店铺运营销售额统计树状图")
    private Result queryShopSales(ShopOperationBO bo) {
        if (bo.getShopId() == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryShopSales(bo));
    }

    @PostMapping(value = "/queryOrderHeader")
    @ApiOperation(value = "订单量统计,店铺运营订单量统计头部数据", notes = "订单量统计,店铺运营订单量统计头部数据")
    private Result queryOrderHeader(Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryOrderHeader(shopId));
    }

    @PostMapping(value = "/queryShopOrderTree")
    @ApiOperation(value = "订单量统计,店铺运营订单量统计树状图", notes = "订单量统计,店铺运营订单量统计树状图")
    private Result queryShopOrderTree(ShopOperationBO bo) {
        if (bo.getShopId() == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryShopOrderTree(bo));
    }

    @PostMapping(value = "/queryShopOrderToDayList")
    @ApiOperation(value = "订单量统计,店铺运营订单量统计今日新增订单列表", notes = "订单量统计,店铺运营订单量统计今日新增订单列表")
    private Result queryShopOrderToDayList(Integer pageNo, Integer pageSize, Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryShopOrderToDayList(pageNo, pageSize, shopId));
    }

    @PostMapping(value = "/queryShopPVUVTree")
    @ApiOperation(value = "PV/UV统计,店铺运营PV/UV，浏览量/访客数树状图", notes = "PV/UV统计,店铺运营PV/UV，浏览量/访客数树状图")
    private Result queryShopPVUVTree(ShopOperationBO bo) {
        if (bo.getShopId() == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryShopPVUVTree(bo));
    }

    @PostMapping(value = "/queryShopGoodsPVUVTree")
    @ApiOperation(value = "店铺运营PV/UV，商品浏览量/商品访客数", notes = "店铺运营PV/UV，商品浏览量/商品访客数")
    private Result queryShopGoodsPVUVTree(ShopOperationBO bo) {
        if (bo.getShopId() == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryGoodsPVUVTree(bo));
    }

    @PostMapping(value = "/queryPVVUHeader")
    @ApiOperation(value = "店铺运营PV/UV,头部数据", notes = "店铺运营PV/UV,头部数据")
    private Result queryPVVUHeader(Long shopId) {
        if (shopId == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(shopOperationService.queryPVVUHeader(shopId));
    }
}
